<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">

<!-- Viewport Metatag -->
<meta name="viewport" content="width=device-width,initial-scale=1.0">

<!-- Plugin Stylesheets first to ease overrides -->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/plugins/colorpicker/colorpicker.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/plugins/fullcalendar/fullcalendar.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/plugins/fullcalendar/fullcalendar.print.css" media="print">

<!-- Required Stylesheets -->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/bootstrap/css/bootstrap.min.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/fonts/ptsans/stylesheet.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/fonts/icomoon/style.css" media="screen">

<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/mws-style.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/icons/icol16.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/icons/icol32.css" media="screen">

<!-- Demo Stylesheet -->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/demo.css" media="screen">

<!-- jQuery-UI Stylesheet -->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/jui/css/jquery.ui.all.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/jui/jquery-ui.custom.css" media="screen">

<!-- Theme Stylesheet -->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/mws-theme.css" media="screen">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/themer.css" media="screen">
<script type="text/javascript" src="__PUBLIC__/Admin/js/libs/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/plugins/layer-v3.1.1/layer/layer.js"></script>
<title>博客后台</title>

</head>

<body>

<div class="mws-panel grid_5">
    <div class="mws-panel-header">
        <span>添加管理员</span>
    </div>

    <div class="mws-panel-body no-padding">
        <form class="mws-form" action="{:U('User/edit')}" id="art_form" method="post" enctype="multipart/form-data">
            <div class="mws-form-inline">

                <div class="mws-form-row">
                    
                    <label class="mws-form-label">用户名</label>
                    <div class="mws-form-item">
                        <input type="text" class="small" name="username" value="{$result['username']}">
                        <input type="hidden" name="id" value="{$result['id']}">
                    </div>
                </div>
                <div class="mws-form-row">
                    <label class="mws-form-label">密码</label>
                    <div class="mws-form-item">
                        <input type="text" class="small" name="password" value="{$result['password']}">
                    </div>
                </div>
                <div class="mws-form-row">
                    <label class="mws-form-label">确认密码</label>
                    <div class="mws-form-item">
                        <input type="text" class="small" name="repassword" value="{$result['password']}">
                    </div>
                </div>
                <div class="mws-form-row">
                    <label class="mws-form-label">姓名</label>
                    <div class="mws-form-item">
                        <input type="text" class="small" name="nikename" value="{$result['nikename']}">
                    </div>
                </div>
                <div style="width:300px;" class="mws-form-row">
                    <label class="mws-form-label">照片</label>
                                    <!-- <input style="width:260px;float:left;" type="text" name="shopinfo_smallpicture" value="" id="shopinfo_smallpicture"> -->
                                    <div style="width:30%;margin-left:155px;">
                                    <div class="fileinput-holder" style="position: relative;">
                                        <input type="text" class="fileinput-preview" style="width: 213px; " readonly="readonly" >
                                        <span class="fileinput-btn btn" type="button" style="display:block; overflow: hidden; position: absolute; top: 0; right: 0; cursor: pointer;">上传图片...
                                            <input type="file"  name="images" style="position: absolute; top: 0px; right: 0px; margin: 0px; cursor: pointer; font-size: 999px; opacity: 0; z-index: 999;"></span></div>
                                            <input type="hidden" name="image" value="{$result['image']}">
                                    </div>
                                        <p> 
                                            <!-- <img src="" alt=""  style="width:90px;height:70px;margin-top:10px;border:2px solid #cccccc;display: none;"> -->
                                </p>
                                </div>
                <!-- <div class="mws-form-row">
                    <label class="mws-form-label">照片</label>
                    <div class="mws-form-item"  style="width: 266px;">
                        <div class="fileinput-holder" style="position: relative;">
                            <span class="fileinput-btn btn" type="button" style="display:block; overflow: hidden; position: absolute;   cursor: pointer;">
                                <!-- 上传图片... -->
                               <!--  <input type="file" class="small"  name="images">

                                <input type="hidden" name="image" value="">
                            </span>
                        </div>
                    </div>
                </div> --> 
                <div class="mws-form-row">
                    <label class="mws-form-label">手机号</label>
                    <div class="mws-form-item">
                        <input type="text" class="small" name="phone" value="{$result['phone']}">
                    </div>
                </div>
                <div class="mws-form-row">
                    <label class="mws-form-label">邮箱</label>
                    <div class="mws-form-item">
                        <input type="text" class="small" name="email" value="{$result['email']}">
                    </div>
                </div>

                <div class="mws-form-row">
                    <label class="mws-form-label">性别</label>
                    <div class="mws-form-item clearfix">
                        <ul class="mws-form-list inline">
                            <li>
                                <input type="radio" name="sex" {$result['sex']=='男'?'checked':''}   value="男"> 
                                <label> 男</label>
                            </li>
                            <li>
                                <input type="radio" name="sex" {$result['sex']=='女'?'checked':''} value="女"> 
                                <label> 女</label>
                            </li>


                        </ul>
                    </div>

                </div>

            </div>

            <div class="mws-button-row">
                <input type="submit" value="添加" class="btn btn-danger">
                <input type="reset" value="重置" class="btn ">
            </div>
        </form>
    </div>      
</div>

<div class="mws-panel grid_3">
      <img src="{$result['image']}" style="height: 420px;width: 320px;"  id="images">  
</div>
<script type="text/javascript">
    $('input[name=images]').change(function(){
         var formData = new FormData($("#art_form")[0]);

             $.ajax({
              url: "{:U('Admin/User/add')}",
              type: "POST",
              data: formData,
              async: true,
              contentType: false, //必须false才会避开jQuery对 formdata 的默认处理 XMLHttpRequest会对 formdata 进行正确的处理 
              processData: false, //必须false才会自动加上正确的Content-Type
              success: function (data) {
                if (data) {
                    // alert(11)
                    $('#images').attr('src',data);
                    $('#images').css('display','block')
                    $('input[name=image]').val(data)                   

                } else {
                    layer.msg('上传失败');
                }
               
              }
        });
            
    })
</script>
</body>

</html>